package com.sykj.springboot.thread.AtomicInteger;

import com.sykj.springboot.common.utils.TimeUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ThreadTest2 {




    /**
     * @author lining
     * @date 2022/6/30 15:28
     * @description 保证线程安全的方式二   使用AtomicInteger
     **/
    public static void main(String[] args) {
        AtomicInteger count = new AtomicInteger(100);
        AtomicInteger totalCount = new AtomicInteger(0);
        ExecutorService executor = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 5; i++) {
            executor.submit(new SellerThred("NAME"+i,count,totalCount));
        }
    }








}
